package com.lanmaoly.cunzheng;

public final class OwnString{
	
	private final char value[];
	
	public OwnString(char[] values) {
		value = values;
	}
	
	private int hash;

	@Override
    public int hashCode() {
        int h = hash;
        if (h == 0 && value.length > 0) {
            char val[] = value;
            
            for (int i = 0; i < value.length; i++) {
                h = 31 * h + val[i];
            }
            hash = h;
        }
        return h;
    }
    
    public static void main(String[] args) {
		OwnString ownString = new OwnString(new char[]{'1'});
		int hashCode = ownString.hashCode();
		System.out.println(hashCode);

		String s = "acfZvCiqgB9SFx5xxw09vAHK0UyHtat/NqtIMxyf9ng0Vj8cJLzDdTdrEiAhaqd47hBn2IazCAgD\n" +
                "L6ypiVAAU8nJLS9BSyXBjUCExkLlz4svIFW+nFLZCGN/LM8JKvM8fVv3kIcR3NeZhmOsMh1uSRMj\n" +
                "I1HJ0S+xPfys9PyLp0kS13oBi7czF4PtFFhFsPPw7fNPL6dCH4Z9nt1qZGcA7scYJSwrOnb4YgpJ\n" +
                "r10twV8DUbAkCn+vS0bhKmO+TevsMzBsRt8fq9jtD7qeBo9bX6GY/tP8kePpCogE8y2KSBJSRcE8\n" +
                "QX3IdT6vKdmHOEp4cOMfO0s1DlmganTEmBfVZw==";
        String s2 = "acfZvCiqgB9SFx5xxw09vAHK0UyHtat/NqtIMxyf9ng0Vj8cJLzDdTdrEiAhaqd47hBn2IazCAgD\n" +
                "L6ypiVAAU8nJLS9BSyXBjUCExkLlz4svIFW+nFLZCGN/LM8JKvM8fVv3kIcR3NeZhmOsMh1uSRMj\n" +
                "I1HJ0S+xPfys9PyLp0kS13oBi7czF4PtFFhFsPPw7fNPL6dCH4Z9nt1qZGcA7scYJSwrOnb4YgpJ\n" +
                "r10twV8DUbAkCn+vS0bhKmO+TevsMzBsRt8fq9jtD7qeBo9bX6GY/tP8kePpCogE8y2KSBJSRcE8\n" +
                "QX3IdT6vKdmHOEp4cOMfO0s1DlmganTEmBfVZw==";
        System.out.println(s.equals(s2));
	}

}
